package io.renren.modules.substation.service.impl;

import io.renren.modules.substation.entity.TInfoAreaInfoEntity;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.substation.dao.TSampJfDataInfoDao;
import io.renren.modules.substation.entity.TSampJfDataInfoEntity;
import io.renren.modules.substation.service.TSampJfDataInfoService;


@Service("tSampJfDataInfoService")
public class TSampJfDataInfoServiceImpl extends ServiceImpl<TSampJfDataInfoDao, TSampJfDataInfoEntity> implements TSampJfDataInfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TSampJfDataInfoEntity> page = this.page(
                new Query<TSampJfDataInfoEntity>().getPage(params),
                new QueryWrapper<TSampJfDataInfoEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public int updateByDevId(TSampJfDataInfoEntity tSampJfDataInfoEntity){

        return baseMapper.updateByDevId(tSampJfDataInfoEntity);
    }

    @Override
    public TSampJfDataInfoEntity queryJfInfoByCondition(TSampJfDataInfoEntity tSampJfDataInfoEntity)
    {
        return baseMapper.queryJfInfoByCondition(tSampJfDataInfoEntity);
    }

    @Override
    public List<TSampJfDataInfoEntity> listOrderByTime() {
        return baseMapper.selectList(new QueryWrapper<TSampJfDataInfoEntity>()
                .orderByDesc("LAST_TIME")
        );
    }

    @Override
    public List<TSampJfDataInfoEntity> listByDev(List<String> devIds) {
        List<TSampJfDataInfoEntity> list = baseMapper.selectList(
                new QueryWrapper<TSampJfDataInfoEntity>()
                        .in(devIds != null && devIds.size() > 0, "DEV_ID", devIds)
        );
        return list;
    }

}